package com.pai4j.pgc.dao.community;
import com.pai4j.pgc.entity.community.CCOpenSourceEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *
 *
 * @author: CYM-pai
 * @date: 2025/10/27 20:00
 **/
@Repository
public interface ICCOpenSourceDAO extends JpaSpecificationExecutor<CCOpenSourceEntity>, JpaRepository<CCOpenSourceEntity, Long> {


    List<CCOpenSourceEntity> findAllByCcIdAndUrl(Long ccId, String url);

    List<CCOpenSourceEntity> findAllByCcIdAndStatusOrderByIdAsc(Long ccId, String status);

    @Query(value = "select os.* from pai4j_open_source os where os.cc_id = :pathId and os.recommend = true " +
            "order by os.recommend_date desc limit :size", nativeQuery = true)
    List<CCOpenSourceEntity> findLimitRecommendList(Long pathId, Integer size);
}
